<?php

/**
 * EmailMessage form base class.
 *
 * @method EmailMessage getObject() Returns the current form's model object
 *
 * @package    ecollegeplus
 * @subpackage form
 * @author     Batanayi Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseEmailMessageForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'from_email'        => new sfWidgetFormInputText(),
      'to_email'          => new sfWidgetFormTextarea(),
      'cc_email'          => new sfWidgetFormTextarea(),
      'bcc_email'         => new sfWidgetFormTextarea(),
      'email_template_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EmailTemplate'), 'add_empty' => true)),
      'sender_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Sender'), 'add_empty' => false)),
      'reply_to'          => new sfWidgetFormInputText(),
      'subject'           => new sfWidgetFormInputText(),
      'body'              => new sfWidgetFormTextarea(),
      'status'            => new sfWidgetFormInputText(),
      'is_read'           => new sfWidgetFormInputCheckbox(),
      'is_trashed'        => new sfWidgetFormInputCheckbox(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'from_email'        => new sfValidatorString(array('max_length' => 255)),
      'to_email'          => new sfValidatorString(array('required' => false)),
      'cc_email'          => new sfValidatorString(array('required' => false)),
      'bcc_email'         => new sfValidatorString(array('required' => false)),
      'email_template_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EmailTemplate'), 'required' => false)),
      'sender_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Sender'))),
      'reply_to'          => new sfValidatorString(array('max_length' => 255)),
      'subject'           => new sfValidatorString(array('max_length' => 255)),
      'body'              => new sfValidatorString(),
      'status'            => new sfValidatorInteger(array('required' => false)),
      'is_read'           => new sfValidatorBoolean(array('required' => false)),
      'is_trashed'        => new sfValidatorBoolean(array('required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('email_message[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'EmailMessage';
  }

}
